package pv


import (
	"kms-backend/controllers"
	"kms-backend/utils/logs"

	"github.com/dotbalo/kubeutils/kubeutils"
	"github.com/gin-gonic/gin"
	corev1 "k8s.io/api/core/v1"
)

func Create(r *gin.Context) {
	// 新增
	logs.Debug(nil, "开始创建pv")
	// pv是否需要自动创建一个headless pv

	var pv corev1.PersistentVolume
	info := controllers.Info{}
	info.Item = &pv
	kubeconfig := controllers.NewInfo(r, &info, "创建pv成功")
	// 使用kubeutils接口创建pv
	var kubeUtilser kubeutils.KubeUtilser
	instance := kubeutils.NewPersistentVolume(kubeconfig, &pv)
	// 把实例赋值给kubeUtilser
	kubeUtilser = instance
	// 使用kubeUtilser创建
	info.Create(r, kubeUtilser)

}
